package com.gxa.controller;

import com.gxa.common.R;
import com.gxa.pojo.Emp;
import com.gxa.pojo.blackPojo.ShowBack;
import com.gxa.pojo.zk.ExcelWrite;
import com.gxa.service.EmpExcelWriteService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.io.IOException;


@Controller
@RequestMapping("/emp_excel")
@Api(value = "员工导入导出" ,tags = "员工导入导出接口")
public class EmpExcelController {

    @Autowired
    private EmpExcelWriteService empExcelWriteService;

    //数据库导出
    @RequestMapping(value = "/excelWrite",method = RequestMethod.POST)
    @ApiOperation(value = "excel导出",notes = "",httpMethod = "POST", response = ShowBack.class)
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    @ResponseBody
    public R excelWrite(ExcelWrite excelWrite) throws IOException {
        return empExcelWriteService.excelsWrite(excelWrite);
    }

    //数据库导入
    @RequestMapping(value = "/excelRead",method = RequestMethod.POST)
    @ApiOperation(value = "excel导入",notes = "",httpMethod = "POST", response = Emp.class)
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    @ResponseBody
    public R excelRead(@RequestBody Emp emp) throws IOException {
        return empExcelWriteService.excelRead(emp);
    }



}
